<?php

// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\{Route, View};

// 通用功能
Route::group(function () {
    Route::get('/', 'Login/index');
    Route::post('login', 'Login/login');
});

// 登录后
Route::group('backend', function () {
    // 无操作权限
    Route::get('no_access', function (){
        return View::fetch('template/index');
    });
    // 首页
    Route::get('index', 'Index/index');
    // 退出
    Route::get('logout', 'Login/logout');

    // 常规管理
    Route::group('general', function () {
        // 我的信息
        Route::rule('index', 'General/index', 'GET|PUT');
        // 上传图片
        Route::post('upload', 'General/upload');
    });

    // 权限管理
    Route::group('auth', function () {
        // 管理员管理
        Route::get('admin/index', 'auth.admin/index');
        Route::rule('admin/add', 'auth.admin/add', 'GET|POST');
        Route::rule('admin/edit/:id', 'auth.admin/edit', 'GET|PUT');
        Route::delete('admin/delete/:id', 'auth.admin/delete');

        // 角色
        Route::get('role/index', 'auth.role/index');
        Route::rule('role/add', 'auth.role/add', 'GET|POST');
        Route::rule('role/edit/:id', 'auth.role/edit', 'GET|PUT');
        Route::delete('role/delete/:id', 'auth.role/delete');
        Route::GET('role/roletree', 'auth.role/roleTree');
    });
});
